@typeparam            T
@using Entity
@using Extension
@inherits DrawerPageBase<T>
<div>

    <Breadcrumb>
        <BreadcrumbItem>@L["Doc"]</BreadcrumbItem>
        <BreadcrumbItem >@_currentRootKey</BreadcrumbItem>
    </Breadcrumb>
    <Divider/>
    <div>
        <Button OnClick="ExpandAll">@L["Expand"]</Button>
        <Button OnClick="CollapseAll">@L["Collapse"]</Button>
    </div>
    <Divider/>

    <GridRow>
        <GridCol Flex=@("200px") Style="border-width: 1px">
            <div>
                <Tree
                    ChildrenExpression="x => x.DataItem.ChildList"
                    DataSource="_dataList"
                    IsLeafExpression="x => x.DataItem.RefKey == null"
                    KeyExpression="x => x.DataItem.Title"
                    OnNodeLoadDelayAsync="OnNodeLoadDelayAsync"
                    OnClick="OnItemClick"
                    @ref="_tree"
                    ShowLeafIcon="false"
                    ShowLine="true"
                    TItem="TreeData"
                    TitleExpression="OnTitleExpression">
                </Tree>
            </div>
        </GridCol>
        <GridCol Flex=@("auto")>
            <Affix OffsetTop="60">
                <div >
                    <Card Title="@_currentItem.Title" Style="max-width:600px">
                        <Body>
                        <p>@_currentItem.description</p>
                        <p>
                            @if (_currentItem.type != null)
                            {
                                <Tag Color="@PresetColor.Volcano.ToString()">@_currentItem.type</Tag>
                            }
                            @if (_currentItem.format != null)
                            {
                                <Tag Color="@PresetColor.Orange.ToString()">@_currentItem.format</Tag>
                            }
                        </p>
                        </Body>
                    </Card>
                    @if (!string.IsNullOrEmpty(_translateResult))
                    {
                        <Card Title="@((AiService.Enabled() ? AiService.Name() : "") + L["Translation"])"
                              Style="max-width:600px">
                            <p>
                                @((MarkupString)_translateResult.ToHtmlDisplay())
                            </p>
                            @if (AiService.Enabled())
                            {
                                <p>
                                    <Button Icon="@IconType.Fill.Frown" Type="@ButtonType.Link"
                                            OnClick="@ReTranslate">
                                        @L["Not satisfied with this translation, retranslate."]
                                    </Button>
                                </p>
                            }
                        </Card>
                    }
                    @if (_currentItem.Title != null && string.IsNullOrEmpty(_translateResult) && AiService.Enabled())
                    {
                        <Card Title="@((AiService.Enabled() ? AiService.Name() : "") + L["Translation"])"
                              Style="max-width:600px">
                            <Spin/>
                        </Card>
                    }
                </div>
            </Affix>
        </GridCol>
    </GridRow>
</div>
